#include"TcpServerMediator.h"
#include"TcpServer.h"
TcpServerMediator::TcpServerMediator()
{
	m_pNet = new TcpServer(this);
}
TcpServerMediator::~TcpServerMediator()
{
	if (m_pNet) {
		delete m_pNet;
		m_pNet = nullptr;
	}
}


//打开网络
bool TcpServerMediator::OpenNet()
{
	if (!m_pNet->InitNet())
	{
		return false;
	}
	return true;
}

//关闭网络
void TcpServerMediator::CloseNet()
{
	m_pNet->UnInitNet();
}

//发送数据
bool TcpServerMediator::SendData(long ISendIp, char* buf, int nLen)
{
	if (!m_pNet->SendData(ISendIp, buf, nLen))
	{
		return false;
	}
	return true;
}

//处理数据
#include<iostream>
void TcpServerMediator::DealData(long ISendIp, char* buf, int nLen)
{
	//把数据传给kernel类
	std::cout << buf << endl;
	this->SendData(ISendIp, buf, nLen);
}


